home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.sprintlink.net!mv!usenet
- From: ENGR@GSSI.MV.COM (Michael Furman)
- Subject: Re: === Repost : Interrupt driven object ===
- Message-ID: <DLC7ux.LuL@mv.mv.com>
- Mime-Version: 1.0
- Organization: GSSI
- Date: Wed, 17 Jan 1996 18:11:21 GMT
- References: <4dj02s$60q@newsbf02.news.aol.com>
- X-Newsreader: WinVN 0.93.10
- X-Nntp-Posting-Host: gssi.mv.com
-
- In article <4dj02s$60q@newsbf02.news.aol.com>, awhang8367@aol.com says...
- >
- >
- >>In article <4d6imm$okq@newsbf02.news.aol.com>, awhang8367@aol.com says...
- >>
- >> I have been struggling to create an object that handles hardware
- >>interrupt directly.
- >.... snip ....
-
- I thought that I answered your question in my previous post. Probably I
- was not clear enough.
-
- >
- >class serial_device:public UART
- >{
- > private :
- > .
- > .
- > .
- > .
- >
- > public :
- > void interrupt far isr(...);
-
- You can't use nonstatic member function as ISR because it takes additional
- hidden argument - pointer to class instance. And hardware interrupt mechanism
- and even OS can not provide it at the interrupt time (because nobody knows
- besides you).
-
- If you are making class for working with just one interrupt you can write
- external interrupt interface static function and use static variable to pass
- pointer to class instance. It will look like:
-
- static serial_device * sdp; // Static variable that holds
- // pointer to only one instance
- // of class
- static void interrupt far ext_isr(......) // external ISR interface
- // function
- {
- sdp->isr(......); // Call your "ISR" function
- }
- void isr(....); // Your "ISR" function
- serial_device(....)
- {
- sdp = this;
- .......
- setvect(...., ext_isr);
- .......
- }
-
- If you need to work with more than one device (using the same class) you need
- a different interface ISR function with different pointer to class instance
- for each interrupt. I know the only one way to do it - generate separate
- assembler stub - interface function with its own pointer for each class
- instance (I described it a little bit more detailed in my previous post).
-
- Also - do not forget about stack. You do not know which stack will be active
- at the interrupt time - it may be DOS stack which is very small. If you
- ISR is more then a couple simple statements you HAVE to provide your own
- stack - interface function is a good place to switch it before call isr()
- and swinch it back after.
-
- If you have further questions - let me know.
-
-
- <<<<< This is a copy of the post to newsgroup >>>>>>
- --
- ---------------------------------------------------------------
- Michael Furman, (603)893-1109
- Geophysical Survey Systems, Inc. fax:(603)889-3984
- 13 Klein Drive - P.O. Box 97 engr@gssi.mv.com
- North Salem, NH 03073-0097 71543.1334@compuserve.com
- ---------------------------------------------------------------
-
-